<form id="setting-form" class="form-horizontal" action="/admin/setting/crypt" method="post" accept-charset="utf-8">
    {% raw xsrf_form_html() %}
    <div class="form-group">
        <label for="project" class="col-md-2 col-lg-1 control-label">所属项目:</label>
        <div class="col-md-2">
            <select id="project" name="project" class="form-control">
                <option value="0" selected>请选择项目</option>
                {% for pj in project_list %}
                <option value="{{ pj.id }}">{{ pj.name }}</option>
                {% end %}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-md-2 col-lg-1 control-label" for="encrypt">加密算法:</label>
        <div class="col-md-2">
            <select id="encrypt" name="encrypt" class="form-control">
                <option value="0" selected>请选择加密算法</option>
                {% for en in encrypt %}
                <option data-toggle="tooltip" data-placement="right" title="{{ en['comment'] }}" value="{{ en['name'] }}">{{ en['name'] }}</option>
                {% end %}
            </select>
        </div>
        <label class="col-md-2 col-lg-1 control-label" for="encrypt-key">加密秘钥(Key):</label>
        <div class="col-md-2">
            <input type="text" id="encrypt-key" name="encrypt-key" class="form-control" placeholder="必填" required>
        </div>
        <label class="col-md-2 col-lg-1 control-label" for="encrypt-iv">加密向量(Iv):</label>
        <div class="col-md-2">
            <input type="text" id="encrypt-iv" name="encrypt-iv" class="form-control" placeholder="没有请留空">
        </div>
    </div>
    <div class="form-group">
        <label class="col-md-2 col-lg-1 control-label" for="decrypt">解密算法:</label>
        <div class="col-md-2">
            <select id="decrypt" name="decrypt" class="form-control">
                <option value="0" selected>请选择解密算法</option>
                {% for de in decrypt %}
                <option data-toggle="tooltip" data-placement="right" title="{{ de['comment'] }}" value="{{ de['name'] }}">{{ de['name'] }}</option>
                {% end %}
            </select>
        </div>
        <label class="col-md-2 col-lg-1 control-label" for="decrypt-key">解密秘钥(Key):</label>
        <div class="col-md-2">
            <input type="text" id="decrypt-key" name="decrypt-key" class="form-control" placeholder="必填" required>
        </div>
        <label class="col-md-2 col-lg-1 control-label" for="decrypt-iv">解密向量(Iv):</label>
        <div class="col-md-2">
            <input type="text" id="decrypt-iv" name="decrypt-iv" class="form-control" placeholder="没有请留空">
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-offset-1 col-md-1">
            <input type="button" id="submit" value="保存" class="btn btn-primary">
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-offset-1 col-md-1">
            <span class="label label-info sr-only" style="font-size:14px;" id="msg"></span>
        </div>
    </div>
</form>
<div class="table-responsive">
    <table class="table table-striped table-hover">
        <thead>
        <tr>
            <th>#</th>
            <th>所属项目</th>
            <th>加密算法</th>
            <th>加密秘钥(Key)</th>
            <th>加密向量(Iv)</th>
            <th>解密算法</th>
            <th>解密秘钥(Key)</th>
            <th>解密向量(Iv)</th>
            <th class="col-md-1">操作</th>
        </tr>
        </thead>
        <tbody>
        {% for i in range(len(lists)) %}
        <tr>
            <td>{{ (page-1)*limit+i+1 }}</td>
            <td>{{ lists[i].project_name }}</td>
            <td>{{ lists[i].value.encrypt.name }}</td>
            <td>{{ lists[i].value.encrypt.key }}</td>
            <td>{{ lists[i].value.encrypt.iv }}</td>
            <td>{{ lists[i].value.decrypt.name }}</td>
            <td>{{ lists[i].value.decrypt.key }}</td>
            <td>{{ lists[i].value.decrypt.iv }}</td>
            <td>
                {% if current_user.role != 2 %}
                <a class="btn btn-danger btn-delete" data-id="{{ lists[i].id }}">删除</a>
                {% end %}
            </td>
        </tr>
        {% end %}
        </tbody>
    </table>
    {% module nav(total_page, page, limit, '/admin/setting/crypt/{}'.format(pid)) %}
</div>